<template>
  <el-dialog
    :visible.sync="visible"
    title="编辑"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    top="100px"
    width="70%"
  >
    <div style="position: relative; margin: -30px 0">
      <el-tabs v-model="activeName">
        <el-tab-pane label="房源信息" name="first">
          <!-- <show-page1 ref="page1"></show-page1> -->
        </el-tab-pane>
        <el-tab-pane label="预订信息" name="second">
          <!-- <show-page2 ref="page2"></show-page2> -->
        </el-tab-pane>
        <el-tab-pane label="房型图片" name="fourth">
          <!-- <show-page2 ref="page2"></show-page2> -->
        </el-tab-pane>
      </el-tabs>
      <el-form
        :model="dataForm"
        :rules="dataRule"
        ref="dataForm"
        class="dialogInner"
        @keyup.enter.native="dataFormSubmitHandle()"
        :label-width="$i18n.locale === 'en-US' ? '170px' : '140px'"
      >
        <el-row :gutter="30">
          <template v-if="activeName == 'first'">
            <el-col :span="12">
              <el-form-item label="房型名称" prop="name">
                <el-input v-model="dataForm.name"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="简称" prop="shortName">
                <el-input v-model="dataForm.shortName"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="可住人数" prop="checkinGuests">
                <el-input-number
                  v-model="dataForm.checkinGuests"
                  :min="0"
                  label="可住人数"
                ></el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="可携带儿童数" prop="childCheckinNums">
                <el-input-number
                  v-model="dataForm.childCheckinNums"
                  :min="0"
                  label="可携带儿童数"
                ></el-input-number>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="12">
              <el-form-item label="房间类型" prop="rentType">
                <el-radio-group v-model="dataForm.rentType">
                  <el-radio :label="1">整栋</el-radio>
                  <el-radio :label="2">单间</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col> -->
            <el-col :span="12">
              <el-form-item label="卧室(间)" prop="bedroom">
                <el-input
                  v-model="dataForm.bedroom"
                  type="number"
                  min="0"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="客厅(个))" prop="livingroom">
                <el-input
                  v-model="dataForm.livingroom"
                  type="number"
                  min="0"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="卫生间(个)" prop="bathroom">
                <el-input
                  v-model="dataForm.bathroom"
                  type="number"
                  min="0"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="床型" prop="">
                <div
                  class="item"
                  v-for="(item, index) in dataForm.bedData"
                  :key="index"
                  style="margin-bottom: 10px"
                >
                  <el-input
                    v-model="item.category"
                    placeholder="请输入床型(如单人床)"
                    style="width: 200px"
                  >
                  </el-input>
                  <el-input
                    v-model="item.size"
                    placeholder="请输入床尺寸(如1.5)"
                    style="width: 200px; margin: 0 15px"
                  >
                  </el-input>
                  <el-input-number
                    v-model="item.num"
                    :min="1"
                    label=""
                  ></el-input-number>
                  <el-link
                    type="danger"
                    style="margin-left: 10px; height: 14px"
                    @click="delBed(index)"
                    >删除</el-link
                  >
                </div>
                <el-button type="primary" @click="addBed()">新增床型</el-button>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="面积: ㎡" prop="area">
                <el-input
                  v-model="dataForm.area"
                  type="text"
                  min="0"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="房源景观" prop="sceneCode">
                <ren-select
                  v-model="dataForm.sceneCode"
                  dict-type="HouseScene"
                  placeholder="请选择"
                ></ren-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="房间号设置" prop="roomFloor" class="rooms">
                <div
                  class="item"
                  v-for="(item, index) in dataForm.roomFloor"
                  :key="index"
                >
                  楼层：<el-input
                    placeholder="楼层如1"
                    v-model="dataForm.roomFloor[index].floor"
                    style="width: 100px; margin-right: 15px"
                  ></el-input>
                  房间号：<el-input
                    placeholder="房号如101"
                    v-model="dataForm.roomFloor[index].roomNumber"
                    style="width: 100px; margin-right: 15px"
                  ></el-input>
                  <i class="el-icon-error" @click="del(index)"></i>
                </div>

                <el-button type="primary" @click="addRoomNo()">新增</el-button>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="房源特色" prop="specialDescribe">
                <el-input
                  type="textarea"
                  :rows="5"
                  placeholder="请输入内容"
                  v-model="dataForm.specialDescribe"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="居家:" prop="homeWith">
                <ren-checkbox-group
                  v-model="dataForm.homeWith"
                  dict-type="HomeWith"
                ></ren-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="卫浴:" prop="bathroomWith">
                <ren-checkbox-group
                  v-model="dataForm.bathroomWith"
                  dict-type="BathroomWith"
                ></ren-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="设施/安全:" prop="hotelSecurity">
                <ren-checkbox-group
                  v-model="dataForm.hotelSecurity"
                  dict-type="HotelSecurity"
                ></ren-checkbox-group>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="娱乐:" prop="hotelRecreation">
                <ren-checkbox-group
                  v-model="dataForm.hotelRecreation"
                  dict-type="HotelRecreation"
                ></ren-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="客房服务:" prop="hotelRoomService">
                <ren-checkbox-group
                  v-model="dataForm.hotelRoomService"
                  dict-type="HotelRoomService"
                ></ren-checkbox-group>
              </el-form-item>
            </el-col>
          </template>
          <!-- 预订信息 -->
          <template v-if="activeName == 'second'">
            <el-col :span="12">
              <el-form-item label="多久提供打扫卫生" prop="clean">
                <el-select
                  v-model="dataForm.houseBook.cleanWashMode.clean"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    :label="item + '扫'"
                    :value="index"
                    v-for="(item, index) in times"
                    :key="item"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="多久提供被单更换" prop="sheet">
                <el-select
                  v-model="dataForm.houseBook.cleanWashMode.sheet"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    :label="item + '换'"
                    :value="index"
                    v-for="(item, index) in times"
                    :key="item"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="多久提供牙具更换" prop="toiletThings">
                <el-select
                  v-model="dataForm.houseBook.cleanWashMode.toiletThings"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    :label="item + '换'"
                    :value="index"
                    v-for="(item, index) in times"
                    :key="item"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="多久提供毛浴巾更换" prop="towel">
                <el-select
                  v-model="dataForm.houseBook.cleanWashMode.towel"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    :label="item + '换'"
                    :value="index"
                    v-for="(item, index) in times"
                    :key="item"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item
                label="退款规则"
                prop="houseBook.refundRule"
                required
              >
                <el-radio-group v-model="dataForm.houseBook.refundRule">
                  <el-radio :label="1">不可取消</el-radio>
                  <el-radio :label="2">免费取消 </el-radio>
                  <el-radio :label="3">限时取消</el-radio>
                </el-radio-group>
                <template v-if="dataForm.houseBook.refundRule == 3">
                  <el-select
                    v-model="dataForm.houseBook.cancelDay"
                    placeholder="请选择"
                    clearable
                    style="width: 120px; margin: 0 15px"
                  >
                    <el-option
                      v-for="(item, index) in times"
                      :label="index == 0 ? '入住当天' : '入住前' + index + '天'"
                      :key="index"
                      :value="index"
                    >
                    </el-option>
                  </el-select>
                  <el-time-picker
                    v-model="dataForm.houseBook.cancelTime"
                    placeholder=""
                    style="width: 120px"
                    value-format="HH:mm"
                    format="HH:mm"
                  >
                  </el-time-picker>
                  <span>前可免费取消</span>
                </template>
              </el-form-item>
            </el-col>
            <el-col :span="24" v-if="dataForm.houseBook.refundRule == 3">
              <el-form-item
                label="扣款类型"
                prop="houseBook.deductType"
                :rules="{
                  required: true,
                  message: this.$t('validate.required'),
                  trigger: 'blur',
                }"
              >
                <el-radio-group v-model="dataForm.houseBook.deductType">
                  <el-radio :label="1">扣首晚房费</el-radio>
                  <el-radio :label="2">扣全额房费 </el-radio>
                  <el-radio :label="3">百分比扣除</el-radio>
                </el-radio-group>
                <el-input
                  :disabled="dataForm.houseBook.deductType != 3"
                  type="number"
                  placeholder=""
                  style="width: 100px; margin: 0 10px"
                  v-model="dataForm.houseBook.deductRatio"
                >
                </el-input
                >%
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="最少预订天数" prop="leastBookDay">
                <el-input
                  type="number"
                  placeholder=""
                  style="width: 80%"
                  v-model="dataForm.houseBook.leastBookDay"
                >
                </el-input
                >天
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="最多预订天数" prop="mostBookDay">
                <el-input
                  type="number"
                  style="width: 60%"
                  placeholder=""
                  v-model="dataForm.houseBook.mostBookDay"
                >
                </el-input
                >天（0为不限）
              </el-form-item>
            </el-col>
          </template>
          <template v-if="activeName == 'fourth'">
            <el-col :span="24">
              <el-form-item label="封面(最多1张)" prop="fileList" required>
                <el-upload
                  class="avatar-uploader"
                  :action="url"
                  :show-file-list="false"
                  :on-success="successHandle1"
                  :before-upload="beforeUploadHandle"
                >
                  <img
                    v-if="dialogImageUrl1"
                    :src="dialogImageUrl1"
                    class="avatar"
                  />
                  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                </el-upload>

                <!-- <el-upload
                  :action="url"
                  :file-list="fileList1"
                  :limit="1"
                  :before-upload="beforeUploadHandle"
                  list-type="picture-card"
                  :on-success="successHandle1"
                  :on-remove="handleRemove1"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible1">
                  <img width="100%" :src="dialogImageUrl1" alt="" />
                </el-dialog> -->
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="卧室(最多10张)" prop="">
                <el-upload
                  :action="url"
                  :file-list="fileList2"
                  :limit="10"
                  :before-upload="beforeUploadHandle"
                  list-type="picture-card"
                  :on-success="successHandle2"
                  :on-remove="handleRemove2"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible2">
                  <img width="100%" :src="dialogImageUrl2" alt="" />
                </el-dialog>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="卫浴(最多10张)" prop="">
                <el-upload
                  :action="url"
                  :file-list="fileList5"
                  :limit="10"
                  :before-upload="beforeUploadHandle"
                  list-type="picture-card"
                  :on-success="successHandle5"
                  :on-remove="handleRemove5"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible5">
                  <img width="100%" :src="dialogImageUrl5" alt="" />
                </el-dialog>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="其他(最多10张)" prop="">
                <el-upload
                  :action="url"
                  :file-list="fileList6"
                  :limit="10"
                  :before-upload="beforeUploadHandle"
                  list-type="picture-card"
                  :on-success="successHandle6"
                  :on-remove="handleRemove6"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible6">
                  <img width="100%" :src="dialogImageUrl6" alt="" />
                </el-dialog>
              </el-form-item>
            </el-col>
          </template>
        </el-row>
      </el-form>
    </div>
    <template slot="footer">
      <el-button type="primary" @click="dataFormSubmitHandle()">{{
        $t("confirm")
      }}</el-button>
    </template>
  </el-dialog>
</template>s

<script>
import Cookies from "js-cookie";
import debounce from "lodash/debounce";
export default {
  data() {
    return {
      dialogImageUrl1: "",
      dialogImageUrl2: "",
      dialogImageUrl3: "",
      dialogImageUrl4: "",
      dialogImageUrl5: "",
      dialogImageUrl6: "",
      dialogVisible1: false,
      dialogVisible2: false,
      dialogVisible3: false,
      dialogVisible4: false,
      dialogVisible5: false,
      dialogVisible6: false,
      visible: false,
      activeName: "first",
      url: `${
        window.SITE_CONFIG["apiURL"]
      }/oss/file/aliyunUpload?access_token=${Cookies.get("access_token")}`,
      fileList1: [],
      fileList2: [],
      fileList3: [],
      fileList4: [],
      fileList5: [],
      fileList6: [],
      dataForm: {
        id: "",
        homestayId: this.$store.state.user.homestayId,
        houseBook: {
          cancelDay: "",
          cancelTime: "",
          checkOutTime: "",
          cleanWashMode: {
            clean: "",
            sheet: "",
            toiletThings: "",
            towel: "",
          },
          deductRatio: 0,
          deductType: "",
          leastBookDay: 0,
          mostBookDay: 0,
          refundRule: "",
        },
        bedData: [
          {
            category: "",
            size: "",
            num: "",
          },
        ],
        area: 0,
        bathroom: 0,
        bedroom: 0,
        fileList: [],
        houseOriginType: 1,
        kitchen: 0,
        livingroom: 0,
        rentType: 2,
        sceneCode: "",
        specialDescribe: "",
        homeWith: [],
        bathroomWith: [],
        hotelRoomService: [],
        hotelSecurity: [],
        hotelRecreation: [],
        houseBaseId: "",
        athroomWith: [], //暂时
        name: "",
        shortName: "",
        checkinGuests: "",
        description: "",
        childCheckinNums: "",
      },
      times: [],
    };
  },
  watch: {},
  computed: {
    dataRule() {
      return {
        name: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        roomFloor: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        rentType: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        bathroom: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        bedroom: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        area: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        houseOriginType: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        livingroom: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
        kitchen: [
          {
            required: true,
            message: this.$t("validate.required"),
            trigger: "blur",
          },
        ],
      };
    },
  },
  created() {
    for (let i = 0; i < 8; i++) {
      if (i == 0) {
        this.times.push("1客1");
      } else {
        this.times.push(i + "天1");
      }
    }
  },
  methods: {
    handleRemove1(file, fileList) {
      this.fileList1 = fileList;
    },
    clear() {
      let id = this.dataForm.id;
      this.dataForm = {
        homestayId: this.$store.state.user.homestayId,
        houseBook: {
          cancelDay: "",
          cancelTime: "",
          checkOutTime: "",
          cleanWashMode: {
            clean: "",
            sheet: "",
            toiletThings: "",
            towel: "",
          },
          deductRatio: 0,
          deductType: "",
          leastBookDay: 0,
          mostBookDay: 0,
          refundRule: "",
        },
        bedData: [
          {
            category: "",
            size: "",
            num: "",
          },
        ],
        area: 0,
        bathroom: 0,
        bedroom: 0,
        fileList: [],
        houseOriginType: 1,
        kitchen: 0,
        livingroom: 0,
        rentType: 2,
        sceneCode: "",
        specialDescribe: "",
        homeWith: [],
        bathroomWith: [],
        hotelRoomService: [],
        hotelSecurity: [],
        hotelRecreation: [],
        houseBaseId: "",
        athroomWith: [],
        roomFloor: [],
        name: "",
        shortName: "",
        checkinGuests: "",
        description: "",
        childCheckinNums: "",
      };
      this.dataForm.id = id;
      this.dataForm.houseBaseId = this.dataForm.id;
    },
    // 上传成功
    successHandle1(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList1 = [
        {
          name: "",
          url: res.data.url,
          picType: 1,
        },
      ];
      this.dialogImageUrl1 = res.data.url;
    },
    handleRemove2(file, fileList) {
      this.fileList2 = fileList;
      //  this.dataForm2.picList=fileList.map((item)=>{return item.url});
    },
    // 上传成功
    successHandle2(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList2.unshift({
        name: "",
        url: res.data.url,
        picType: 2,
      });
    },
    handleRemove3(file, fileList) {
      this.fileList3 = fileList;
    },
    // 上传成功
    successHandle3(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList3.unshift({
        name: "",
        url: res.data.url,
        picType: 3,
      });
    },
    handleRemove4(file, fileList) {
      this.fileList4 = fileList;
    },
    // 上传成功
    successHandle4(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList4.unshift({
        name: "",
        url: res.data.url,
        picType: 4,
      });
    },
    handleRemove5(file, fileList) {
      this.fileList5 = fileList;
    },
    // 上传成功
    successHandle5(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList5.unshift({
        name: "",
        url: res.data.url,
        picType: 5,
      });
    },
    handleRemove6(file, fileList) {
      this.fileList6 = fileList;
    },
    // 上传成功
    successHandle6(res, file, fileList) {
      if (res.code !== 0) {
        return this.$message.error(res.msg);
      }
      this.fileList6.unshift({
        name: "",
        url: res.data.url,
        picType: 6,
      });
    },

    // 上传之前
    beforeUploadHandle(file) {
      if (
        file.type !== "image/jpg" &&
        file.type !== "image/jpeg" &&
        file.type !== "image/png" &&
        file.type !== "image/gif"
      ) {
        this.$message.error(
          this.$t("upload.tip", {
            format: "jpg、png、gif",
          })
        );
        return false;
      }
    },
    init() {
      this.visible = true;
      this.$nextTick(() => {
        this.dataForm.bedData = [];
        this.$refs["dataForm"].resetFields();
        this.clear();
        console.log(this.dataForm.id);
        if (this.dataForm.id) {
          this.dataForm.houseBaseId = this.dataForm.id;
          this.getInfo();
        }
      });
    },
    addRoomNo() {
      this.dataForm.roomFloor.push({
        floor: "",
        roomNumber: "",
      });
    },
    del(ind) {
      this.dataForm.roomFloor.splice(ind, 1);
    },
    addBed() {
      this.dataForm.bedData.push({
        category: "",
        size: "",
        num: "",
      });
    },
    delBed(i) {
      this.dataForm.bedData.splice(i, 1);
    },
    // 获取信息
    getInfo() {
      this.dialogImageUrl1 = "";
      this.fileList1 = [];
      this.fileList2 = [];
      this.fileList3 = [];
      this.fileList4 = [];
      this.fileList5 = [];
      this.fileList6 = [];
      this.$http
        .get("/hotel/house/base/" + this.dataForm.id)
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          if (res.data) {
            let houseBook = this.dataForm.houseBook;
            this.dataForm = {
              ...this.dataForm,
              ...res.data,
            };
            this.dataForm.sceneCode = this.dataForm.sceneCode || "";

            if (!res.data.houseBook) {
              this.dataForm.houseBook = houseBook;
            }
            if (this.dataForm.fileList.length == 0) {
              this.dataForm.fileList = [];
            } else {
              for (let i = 0; i < this.dataForm.fileList.length; i++) {
                if (this.dataForm.fileList[i].picType == 1) {
                  this.fileList1.unshift(this.dataForm.fileList[i]);
                  this.dialogImageUrl1 = this.dataForm.fileList[i].url;
                } else if (this.dataForm.fileList[i].picType == 2) {
                  this.fileList2.unshift(this.dataForm.fileList[i]);
                } else if (this.dataForm.fileList[i].picType == 3) {
                  this.fileList3.unshift(this.dataForm.fileList[i]);
                } else if (this.dataForm.fileList[i].picType == 4) {
                  this.fileList4.unshift(this.dataForm.fileList[i]);
                } else if (this.dataForm.fileList[i].picType == 5) {
                  this.fileList5.unshift(this.dataForm.fileList[i]);
                } else if (this.dataForm.fileList[i].picType == 6) {
                  this.fileList6.unshift(this.dataForm.fileList[i]);
                }
              }
            }
            //处理服务实施数据
          } else {
            this.dataForm.id = "";
          }
        })
        .catch(() => {});
    },
    // 表单提交
    dataFormSubmitHandle() {
      if (this.fileList1.length == 0) {
        return this.$message.error("请上传封面");
      }
      this.dataForm.fileList = [];
      this.dataForm.fileList = this.fileList1.concat(
        this.fileList2,
        this.fileList3,
        this.fileList4,
        this.fileList5,
        this.fileList6
      );
      this.$refs["dataForm"].validate((valid) => {
        if (!valid) {
          return false;
        }
        if (this.dataForm.houseBook.refundRule == 3) {
          if (this.dataForm.houseBook.cancelTime == null) {
            this.dataForm.houseBook.cancelTime = "";
          }
          console.log(this.dataForm.houseBook);
          if (
            this.dataForm.houseBook.deductType === "" ||
            this.dataForm.houseBook.cancelDay === "" ||
            this.dataForm.houseBook.cancelTime === "" ||
            (this.dataForm.houseBook.deductType === 3 &&
              this.dataForm.houseBook.deductRatio === "")
          ) {
            return this.$message.error("必填项填写不完整");
          }
        } else if (this.dataForm.houseBook.refundRule === "") {
          return this.$message.error("请选择退款规则");
        }
        this.$http
          .put("/hotel/house/base", this.dataForm)
          .then(({ data: res }) => {
            if (res.code !== 0) {
              return this.$message.error(res.msg);
            }
            this.$message({
              message: this.$t("prompt.success"),
              type: "success",
              duration: 500,
              onClose: () => {
                this.visible = false;
                this.$emit("refreshDataList");
              },
            });
          })
          .catch(() => {});
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.btn {
  text-align: right;
  padding: 20px 0 0;
  position: absolute;
  width: 100%;
  left: 0;
  bottom: 0;
  z-index: 1;
  background-color: #fff;
  box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.06);
}

.pos {
  position: relative;
}
.rooms .item {
  display: inline-block;
  margin-right: 15px;
  margin-bottom: 10px;
  position: relative;
  background: #f5f5f5;
  padding: 5px 10px;

  .el-icon-error {
    font-size: 20px;
    color: #dd0606;
  }
}
</style>
